/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "accountreceivable")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Accountreceivable.findAll", query = "SELECT a FROM Accountreceivable a"),
    @NamedQuery(name = "Accountreceivable.findByAccountReceivableId", query = "SELECT a FROM Accountreceivable a WHERE a.accountReceivableId = :accountReceivableId"),		
    @NamedQuery(name = "Accountreceivable.findByClientId", query = "SELECT a FROM Accountreceivable a WHERE a.clientId.clientId = :clientId"),
    @NamedQuery(name = "Accountreceivable.findByPharmacyIdByUserId", query = "SELECT a FROM Accountreceivable a WHERE a.userpharmacy.userpharmacyPK.pharmacyId = :pharmacyId AND a.userpharmacy.userpharmacyPK.userId = :userId"),
    @NamedQuery(name = "Accountreceivable.findByClientIdByPharmacyIdByUserId", query = "SELECT a FROM Accountreceivable a WHERE a.clientId.clientId = :clientId AND a.userpharmacy.userpharmacyPK.pharmacyId = :pharmacyId AND a.userpharmacy.userpharmacyPK.userId = :userId"),
    @NamedQuery(name = "Accountreceivable.findByDate", query = "SELECT a FROM Accountreceivable a WHERE a.date = :date"),
    @NamedQuery(name = "Accountreceivable.findByAmount", query = "SELECT a FROM Accountreceivable a WHERE a.amount = :amount"),
    @NamedQuery(name = "Accountreceivable.findByRemark", query = "SELECT a FROM Accountreceivable a WHERE a.remark = :remark"),
    @NamedQuery(name = "Accountreceivable.findByActive", query = "SELECT a FROM Accountreceivable a WHERE a.active = :active")})
public class Accountreceivable implements Serializable {
    private static final long serialVersionUID = 1L;
    /*
    @Id
    @Basic(optional = false)
    @Column(name = "accountReceivableId")
    */
    @Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer accountReceivableId;
    @Basic(optional = false)
    @Column(name = "date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "amount")
    private Float amount;
    @Column(name = "remark")
    private String remark;
    @Column(name = "active")
    private Boolean active;
    @OneToMany(mappedBy = "accountReceivableId")
    private Collection<Paymentplan> paymentplanCollection;
    @JoinColumn(name = "clientId", referencedColumnName = "clientId")
    @ManyToOne
    private Client clientId;
    @JoinColumns({
        @JoinColumn(name = "pharmacyId", referencedColumnName = "pharmacyId"),
        @JoinColumn(name = "userId", referencedColumnName = "userId")})
    @ManyToOne
    private Userpharmacy userpharmacy;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "accountreceivable")
    private Collection<Credititem> credititemCollection;

    public Accountreceivable() {
    }

    public Accountreceivable(Integer accountReceivableId) {
        this.accountReceivableId = accountReceivableId;
    }

    public Accountreceivable(Integer accountReceivableId, Date date) {
        this.accountReceivableId = accountReceivableId;
        this.date = date;
    }

    public Integer getAccountReceivableId() {
        return accountReceivableId;
    }

    public void setAccountReceivableId(Integer accountReceivableId) {
        this.accountReceivableId = accountReceivableId;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Float getAmount() {
        return amount;
    }

    public void setAmount(Float amount) {
        this.amount = amount;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    @XmlTransient
    public Collection<Paymentplan> getPaymentplanCollection() {
        return paymentplanCollection;
    }

    public void setPaymentplanCollection(Collection<Paymentplan> paymentplanCollection) {
        this.paymentplanCollection = paymentplanCollection;
    }

    public Client getClientId() {
        return clientId;
    }

    public void setClientId(Client clientId) {
        this.clientId = clientId;
    }

    public Userpharmacy getUserpharmacy() {
        return userpharmacy;
    }

    public void setUserpharmacy(Userpharmacy userpharmacy) {
        this.userpharmacy = userpharmacy;
    }

    @XmlTransient
    public Collection<Credititem> getCredititemCollection() {
        return credititemCollection;
    }

    public void setCredititemCollection(Collection<Credititem> credititemCollection) {
        this.credititemCollection = credititemCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accountReceivableId != null ? accountReceivableId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Accountreceivable)) {
            return false;
        }
        Accountreceivable other = (Accountreceivable) object;
        if ((this.accountReceivableId == null && other.accountReceivableId != null) || (this.accountReceivableId != null && !this.accountReceivableId.equals(other.accountReceivableId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Accountreceivable[ accountReceivableId=" + accountReceivableId + " ]";
    }
    
}
